// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   GTSBase.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.common.VersionInfo;
import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.GTS;
import com.sunwayhorizo.health.hl7.datatypes.INT;
import com.sunwayhorizo.health.hl7.datatypes.IVL_TS;
import com.sunwayhorizo.health.hl7.datatypes.SET_TS;
import com.sunwayhorizo.health.hl7.datatypes.ST;
import com.sunwayhorizo.health.hl7.datatypes.TS;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;
import com.sunwayhorizo.health.hl7.datatypes.common.gtsparser.ParseException;
import com.sunwayhorizo.health.hl7.datatypes.common.gtsparser.TimeParser;
import com.sunwayhorizo.health.hl7.datatypes.common.gtsparser.TimeParserConstants;
import com.sunwayhorizo.health.hl7.datatypes.common.gtsparser.Token;

import java.util.Set;


// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            ANYImpl, GTSDifferenceImpl, GTSHullImpl, GTSIntersectionImpl, 
//            GTSUnionImpl, IVL_TSImpl, NullFlavorImpl, STImpl, 
//            TYPEImpl

public abstract class GTSBase extends ANYImpl
    implements GTS
{

    public static final String RCS_ID = "$Header: GTSBase.java 115.23.2050.5 2006/02/22 05:18:45 mmoores noship $";
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: GTSBase.java 115.23.2050.5 2006/02/22 05:18:45 mmoores noship $", "oracle.apps.ctb.hl7.types.common");
    protected TYPE _dataType;
    ST _literal;

    protected GTSBase()
    {
        _dataType = com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.GTS;
        _literal = null;
    }

    protected GTSBase(CS cs)
    {
        super(true, cs);
        _dataType = com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.GTS;
        _literal = null;
    }

    public BL equal(ANY any)
    {
        throw ANYImpl.newUnsupportedException("GTS", "equal");
    }

    public BL isEmpty()
    {
        throw ANYImpl.newUnsupportedException("GTS", "isEmpty");
    }

    public BL notEmpty()
    {
        return isEmpty().not();
    }

    public BL contains(TS ts)
    {
        throw ANYImpl.newUnsupportedException("GTS", "contains");
    }

    public BL contains(SET_TS set_ts)
    {
        throw ANYImpl.newUnsupportedException("GTS", "contains");
    }

    public INT cardinality()
    {
        throw ANYImpl.newUnsupportedException("GTS", "cardinality");
    }

    public SET_TS union(SET_TS set_ts)
    {
        if(isNull().isTrue())
            return set_ts;
        if(set_ts.isNull().isTrue())
            return this;
        else
            return GTSUnionImpl.valueOf(this, (GTS)set_ts);
    }

    public SET_TS union(TS ts)
    {
        if(ts.isNull().isTrue())
            return this;
        IVL_TS ivl_ts = IVL_TSImpl.valueOf(ts);
        if(isNull().isTrue())
            return GTSHullImpl.valueOf(ivl_ts);
        else
            return union(((SET_TS) (ivl_ts)));
    }

    public SET_TS intersection(SET_TS set_ts)
    {
        if(isNull().isTrue())
            return this;
        if(set_ts.isNull().isTrue())
            return set_ts;
        else
            return GTSIntersectionImpl.valueOf(this, (GTS)set_ts);
    }

    public SET_TS except(SET_TS set_ts)
    {
        if(isNull().or(set_ts.isNull()).isTrue())
            return this;
        else
            return GTSDifferenceImpl.valueOf(this, (GTS)set_ts);
    }

    public SET_TS except(TS ts)
    {
        if(isNull().or(ts.isNull()).isTrue())
        {
            return this;
        } else
        {
            IVL_TS ivl_ts = IVL_TSImpl.valueOf(ts);
            return except(((SET_TS) (ivl_ts)));
        }
    }

    protected String generateLiteral()
    {
        throw ANYImpl.newUnsupportedException(dataType().shortName().literal().stringValue(), "generateLiteral");
    }

    public ST literal()
    {
        if(isNull().isTrue())
            return STImpl.nullST(NullFlavorImpl.NI);
        if(_literal == null)
            _literal = STImpl.valueOf(generateLiteral());
        return _literal;
    }

    public Set toSet()
    {
        throw ANYImpl.newUnsupportedException("GTS", "toSet");
    }

    public IVL_TS hull()
    {
        throw ANYImpl.newUnsupportedException("GTS", "hull");
    }

    public String toString()
    {
        String s = literal().stringValue();
        if(s == null)
            return "<Null:" + nullFlavor().toString() + ">";
        else
            return s;
    }

    protected static void checkParserState(TimeParser timeparser)
        throws ParseException
    {
        Token token = timeparser.token;
        if(token.next == null)
            token.next = timeparser.token_source.getNextToken();
        if(token.next.kind != 0)
            throw new ParseException(token, new int[0][0], TimeParserConstants.tokenImage);
        else
            return;
    }

//    public XMLNode[] writeXML(XMLDocument xmldocument, String s)
//        throws Hl7Exception
//    {
//        try
//        {
//            XMLElement xmlelement = (XMLElement)xmldocument.createElement(s);
//            xmlelement.setAttribute("value", toString());
//            return (new XMLNode[] {
//                xmlelement
//            });
//        }
//        catch(Exception exception)
//        {
//            throw new Hl7Exception(exception);
//        }
//    }

}
